package com.ag.dgm.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ag.bean.TbPlanScope;
import com.ag.bean.TbPlanScope;
import com.ag.common.AgException;
import com.ag.common.IDServiceImpl;
import com.ag.common.IDUtil;
import com.ag.dgm.dao.TbPlanScopeDAO;
import com.ag.dgm.dao.TbPlanScopeDAO;
import com.ag.dgm.service.PlanScopeService;

/**
 * PlanScope�����ӿ�ʵ��
 * 
 * @author �˹���
 * 
 */
@Service("planScopeService")
public class PlanScopeServiceImpl implements PlanScopeService {
	@Resource(name="DGMTbPlanScopeDAO")
	private TbPlanScopeDAO tbPlanScopeDAO;
	@Resource(name="iDServiceImpl")
	private IDServiceImpl idService;
	
	public void setTbPlanScopeDAO(TbPlanScopeDAO tbPlanScopeDAO) {
		this.tbPlanScopeDAO = tbPlanScopeDAO;
	}



	@Override
	public void add(TbPlanScope tbPlanScope) {	
		String IDs=null;
		try {
			IDs = idService.findTablePK(IDUtil.TB_PLAN_SCOPE);
		} catch (AgException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		tbPlanScope.setPsId(IDs);
		tbPlanScopeDAO.save(tbPlanScope);
	}
	
	public void delete(TbPlanScope ptr){
		TbPlanScope tbPlanScope = tbPlanScopeDAO.findById(ptr.getPsId());
		tbPlanScopeDAO.delete(tbPlanScope);
	}

	@Override
	public void modify(TbPlanScope tbPlanScope) {
		tbPlanScopeDAO.attachDirty(tbPlanScope);		
	}



	@Override
	public List<TbPlanScope> findAll() {		
		return tbPlanScopeDAO.findAll();
	}

}
